package com.jsy.mini12306.ticketsales.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jsy.mini12306.common.entity.TrainCalendar;
import com.jsy.mini12306.ticketsales.mapper.TrainCalendarMapper;
import com.jsy.mini12306.ticketsales.service.TrainCalendarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import lombok.extern.slf4j.Slf4j;

import java.time.LocalDate;


/**
 * 列车行驶日期图(TrainCalendar)表服务实现类
 *
 * @author: SongyangJi
 * @since: 2021-09-02 21:10:06
 * @description:
 */

@Slf4j
@Service("trainCalendarService")
public class TrainCalendarServiceImpl extends ServiceImpl<TrainCalendarMapper, TrainCalendar> implements TrainCalendarService {
    @Resource
    private TrainCalendarMapper trainCalendarMapper;

    @Override
    public boolean isWorking(int trainId, LocalDate date) {
        return trainCalendarMapper.selectCount(new QueryWrapper<TrainCalendar>().eq("train_id", trainId).eq("work_date", date)) > 0;
    }

}
